import { Label, Node, UITransform, Vec3, _decorator } from 'cc';
import { DataItemComponent, DataItemLayout } from '../../../Core/DataItemLayout';
const { ccclass, property } = _decorator;

/**
 * 248139929
 * Mon Apr 22 2024 19:08:10 GMT+0800 (中国标准时间)
 */

@ccclass('ArenaRankILItem')
export class ArenaRankILItem extends DataItemComponent<{name:string, score:number, sols:{icon:number, quality:number}[]}> {
    
    @property(UITransform)
    trans:UITransform

    @property(Label)
    rankLabel:Label
    @property(Label)
    nameLabel:Label
    @property(Label)
    scoreLabel:Label

    @property(DataItemLayout)
    solLayout:DataItemLayout

    /**设置数据 */
    setData(data: {name:string, score:number, sols:{icon:number, quality:number}[]}) {
        this.rankLabel.string = `${this.idx + 1}`
        this.nameLabel.string = data.name
        this.scoreLabel.string = `${data.score}`
    }
    
    refToggleType(isSelect: boolean) {
        if(isSelect){
            this.trans.node.active = true
            if(this.curData.sols.length > this.solLayout.constraintNum){
                this.changeExpand(350)
                this.trans.height = 350
            }else{
                this.changeExpand(246)
                this.trans.height = 246
            }

            this.solLayout.bindDatas(this.curData.sols)
        }else{
            this.changeExpand(124)
            this.trans.height = 124
            this.trans.node.active = false
        }
    }
}
